<template>
  <div>
    <div class="login-container">
      <div class="login_but_container">
        <div class="login_input">
          <el-form
            :label-position="labelPosition"
            label-width="80px"
            :model="formlogin"
            ref="loginFormRef"
          >
            <el-input
              v-model="formlogin.username"
              class="ipt_wrapper"
              placeholder="请输入账号"
            ></el-input>
            <el-input
              type="password"
              v-model="formlogin.password"
              placeholder="请输入密码"
            ></el-input>
          </el-form>
        </div>
      </div>
      <button class="login_container" @click="addLogin">登录呗</button>
    </div>
  </div>
</template>

<script>
import { login } from "../http/http";
export default {
  data() {
    return {
      labelPosition: "right",
      formlogin: {
        username: "admin",
        password: "admin",
      },
    };
  },
  methods: {
    //   点击登录
    async addLogin() {
      this.$refs.loginFormRef.validate(async (val) => {
        if (!val) return;
        const { data: res } = await login(this.formlogin);

        if (res.data.status == 0) return this.$message.error("登录失败！");
        this.$message.success("登录成功！");
        this.$router.push("/dashboard");
      });
    },
  },
};
</script>

<style scoped>
.login-container {
  width: 400px;
  height: 300px;
 
  margin: 10vh auto;
}
.login_input {
  width: 80%;
  margin: 0 auto;
}
.ipt_wrapper {
  margin: 20px 0;
}
.login_container {
  width: 80%;
  height: 40px;
  border: none;
  outline: none;
  background-color:lightblue;
  color: white;
  margin: 20px 10%;
}
.login_top_container {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: center;
  height: 60px;
  justify-content: center;
  border-bottom: 1px solid black;
  font-size: 28px;
  font-weight: 600;
}
</style>
